package com.yhd.tomcat.resp;

import java.io.IOException;
import java.io.OutputStream;

/**
 * @author yhd
 * @email yinhuidong1@xiaomi.com
 * @description TODO
 * @since 2021/6/10 下午5:56
 */
public class HttpResponse extends BaseResponse{

    public HttpResponse(OutputStream os) {
        super(os);
    }

    @Override
    public void write(String msg) {
        StringBuilder sb = new StringBuilder();
        sb.append("HTTP/1.1 200 OK\n")
                .append("Content-Type: text/html;\n")
                .append("\r\n")
                .append(msg);
        try {
            getOs().write(sb.toString().getBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
